"""p6_421_django URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.urls import path
from .views import *
from rest_framework.routers import DefaultRouter

router = DefaultRouter()

router.register("cate", CateSet)
router.register("brands", BrandViewSet)
router.register("skus", SKUViewSet)
router.register("spus", SPUViewSet)
router.register("spuSpecs", SPUSpecViewSet)
router.register("specsOption",SpecOptionSet)
router.register("imgs", SKUImageViewSet)


urlpatterns = [
    # 加载所有的频道组
    path("channels/", ListChannelAPIView.as_view()),
    # 加载所有的商品类别
    path("categories/", CateListAPIView.as_view()),
    # 更新一个，删除一个，查看一个 频道组
    path("channels/<int:pk>/", ChannelInfoAPIView.as_view()),

    # 获取所有的一级类别
    path("channels/firstCate/", FirstCateAPIView.as_view()),
    # 添加频道组
    path("channelsAdd/", AddChannelView.as_view()),

    # 获取子级类别
    path("channels/subCate/<int:pk>/", SubCateAPIView.as_view()),

    # 加载spu的接口
    path("spulist/",SPUListViewSet.as_view()),

    # 加载规格的接口
    path("specs/", SPUSpecList.as_view()),

    # 加载sku数据的接口
    path("skulist/", SKUListAPIView.as_view()),

    # 上传商品图片的接口
    path("sku_image/", UploadSKUImageAPIView.as_view()),

    # 生成七牛云的token
    path("qiniu_token/", QiniuTokenAPIView.as_view()),

    # 获取全部sku数据 添加一个sku数据
    # path("skus/", SKUListCreate.as_view()),

    # 删除一个sku数据个sku数 更新一个sku数据 获取一据
    # path("skus/<int:pk>/", SKUOneAPIView.as_view()),

]

urlpatterns += router.urls